﻿<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@page import="com.zaofan.bean.Admin"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<%
	String contextPath = request.getContextPath();
	Admin admin = (Admin)session.getAttribute("admin");
	if(admin == null){
		response.sendRedirect(contextPath + "/login.jsp?state=" + "session-invalid");
		return;
	}
%>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>动态管理</title>
<link href="<%=contextPath%>/admin/css/base.css" rel="stylesheet" />
<link href="<%=contextPath%>/admin/assets/css/bootstrap.min.css" rel="stylesheet" />
<link rel="stylesheet" href="<%=contextPath%>/admin/assets/css/font-awesome.min.css" />
<!--[if IE 7]>
	<link rel="stylesheet" href="<%=contextPath%>/admin/assets/css/font-awesome-ie7.min.css" />
<![endif]-->
<link rel="stylesheet" href="<%=contextPath%>/admin/assets/css/ace.min.css" />
<link rel="stylesheet" href="<%=contextPath%>/admin/assets/css/ace-rtl.min.css" />
<link rel="stylesheet" href="<%=contextPath%>/admin/assets/css/ace-skins.min.css" />
<!--[if lte IE 8]>
	<link rel="stylesheet" href="<%=contextPath%>/admin/assets/css/ace-ie.min.css" />
<![endif]-->
<script src="<%=contextPath%>/admin/assets/js/ace-extra.min.js"></script>
<!--[if lt IE 9]>
	<script src="<%=contextPath%>/admin/assets/js/html5shiv.js"></script>
	<script src="<%=contextPath%>/admin/assets/js/respond.min.js"></script>
<![endif]-->
<link rel="stylesheet" href="<%=contextPath%>/admin/assets/css/jquery-ui-1.10.3.custom.min.css" />
<link rel="stylesheet" href="<%=contextPath%>/admin/assets/css/chosen.css" />
<script type="text/javascript">  
       var contextPath='<%=contextPath%>';
</script>
</head>
<body style="background-color: #fff;">
	<div class="breadcrumbs" id="breadcrumbs">
		<script type="text/javascript">
			try {
				ace.settings.check('breadcrumbs', 'fixed')
			} catch (e) {
			}
		</script>
		<ul class="breadcrumb" style="padding:20px;color:#3a87ad;">
		</ul>
	</div>
	<div class="page-content">
		<div class="row" style="height: 100%">
			<div class="col-xs-12">
				<button type="button" class="btn btn-primary" id="addArticle">增加</button>
			<style>
				.table-responsive table th tr{text-align: center;}
			</style>
				<div class="table-responsive">
					<input type="hidden" value="1" id="start" />
					<table id="sample-table-2"
						class="table table-striped table-bordered table-hover">
						<thead>
							<tr>
								<th style="text-align: center;">内容</th>
								<th style="text-align: center;">图片</th>
								<th style="text-align: center;">发布者</th>
								<th style="text-align: center;">号码</th>
								<th style="text-align: center;">添加时间</th>
								<th style="text-align: center;">评论数</th>
								<th style="text-align: center;">赞数</th>
								<th style="text-align: center;">状态</th>
								<th style="text-align: center;">操作</th>
							</tr>
						</thead>
						<tbody id="data-list"  style="text-align: center;">
							<c:forEach items="${dynamics }" var="dynamic">
								<tr>
									<td style="width:600px;overflow: hidden;">${dynamic.content }</td>
									<td>
									<c:set value="${ fn:split(dynamic.image, ',') }" var="images" />
									<c:forEach items="${images }" var="item">
										<a href="<%=contextPath %>${item}" target="_blank"><img width="100" height="80" src="<%=contextPath %>${item }" /></a>
									</c:forEach>
									</td>
									<td>${dynamic.userName }</td>
									<td>${dynamic.userMobile }</td>
									<td>${dynamic.addTime }</td>
									<td>
										${dynamic.count }<br/><br/>
										<a href="dynamicReply?action=list&dynamicId=${dynamic.id }&replyType=1">查看回复</a>
									</td>
									<td>
										${dynamic.praise }<br/><br/>
										<a href="dynamicReply?action=list&dynamicId=${dynamic.id }&replyType=0">查看赞</a>
									</td>
									<td>
										<c:choose>
											<c:when test="${dynamic.isDelete == 0 }">
												未删除
																								
											</c:when>
											<c:when test="${dynamic.isDelete == 1 }">
												删除
											</c:when>
										</c:choose>
										<br/><br/>
										<c:choose>
											<c:when test="${dynamic.type == 1 }">
												普通
											</c:when>
											<c:when test="${dynamic.type == 2 }">
												精选
											</c:when>
										</c:choose>
									</td>
									<td>
										<c:choose>
											<c:when test="${dynamic.isDelete == 0 }">
												&nbsp;&nbsp;<a href="javascript:void(0)" class="del" dynamicId="${dynamic.id }" >删除</a>
											</c:when>
											<c:when test="${dynamic.isDelete == 1 }">
												&nbsp;&nbsp;<a href="javascript:void(0)" class="del" dynamicId="${dynamic.id }" >恢复</a>
											</c:when>
										</c:choose>
										<c:choose>
											<c:when test="${dynamic.type == 1 }">
												&nbsp;&nbsp;<a href="javascript:void(0)" class="type" dynamicId="${dynamic.id }" >精选</a>
											</c:when>
											<c:when test="${dynamic.type == 2 }">
												&nbsp;&nbsp;<a href="javascript:void(0)" class="type" dynamicId="${dynamic.id }" >普通</a>
											</c:when>
										</c:choose>
									</td>
								</tr>
							</c:forEach>
						</tbody>
					</table>
				</div>
			</div>
			<!-- /.col -->
		</div>
		<!-- /.row -->
		<div class="row">
			<div class="col-sm-6">
				<div id="sample-table-2_info" class="dataTables_info">
					当前    <span id="current">${pageBean.begin }  </span> 到  <span id="page">${pageBean.end } </span> 总共 <span
						id="total">${pageBean.total } </span> 条
				</div>
			</div>
			<div class="col-sm-6">
				<div class="dataTables_paginate paging_bootstrap">
					<ul class="pagination pagination-sm" id="page-list">
							${pageBean.pageInfo } 
					</ul>
				</div>
			</div>
		</div>
	</div>
	<div id="loading"
		style="width: 32px; height: 32px; position: fixed; left: 40%; top: 40%; display: none;">
		<img src="<%=contextPath%>/admin/assets/css/images/loading.gif"
			width="32" height="32" />
	</div>
	<div class="popover"
		style="z-index: 9999; width: 150px; position: fixed; left: 40%; top: 40%;">
		<div class="arrow"></div>
		<div class="popover-inner">
			<h3 class="popover-title">操作提示</h3>
			<div class="popover-content" id="popover-content">
				<p>操作成功</p>
			</div>
		</div>
	</div>
	
	<script type="text/javascript">
		if ("ontouchend" in document)
			document
					.write("<script src='<%=contextPath%>/admin/assets/js/jquery.mobile.custom.min.js'>"
							+ "<"+"/script>");
	</script>
	<script type="text/javascript">
		window.jQuery
				|| document
						.write("<script src='<%=contextPath%>/admin/assets/js/jquery-2.0.3.min.js'>"
								+ "<"+"script>");
	</script>
	
	<!--[if IE]>
		<script type="text/javascript">
			window.jQuery || document.write("<script src='<%=contextPath%>/admin/assets/js/jquery-1.10.2.min.js'>"+"<"+"script>");
		</script>
	<![endif]-->
	<script type="text/javascript">
		if ("ontouchend" in document)
			document
					.write("<script src='<%=contextPath%>/admin/assets/js/jquery.mobile.custom.min.js'>"
							+ "<"+"script>");
	</script>
	<script src="<%=contextPath%>/admin/assets/js/bootstrap.min.js"></script>
	<script src="<%=contextPath%>/admin/assets/js/typeahead-bs2.min.js"></script>

	<!--[if lte IE 8]>
		  <script src="assets/js/excanvas.min.js"></script>
	<![endif]-->
	<script src="<%=contextPath%>/admin/assets/js/jquery-ui-1.10.3.custom.min.js"></script>
	<script src="<%=contextPath%>/admin/assets/js/jquery.ui.touch-punch.min.js"></script>
	<script src="<%=contextPath%>/admin/assets/js/jquery.slimscroll.min.js"></script>
	<script src="<%=contextPath%>/admin/assets/js/jquery.easy-pie-chart.min.js"></script>
	<script src="<%=contextPath%>/admin/assets/js/jquery.sparkline.min.js"></script>
	<script src="<%=contextPath%>/admin/assets/js/ace-elements.min.js"></script>
	<script src="<%=contextPath%>/admin/assets/js/ace.min.js"></script>
	<script src="<%=contextPath%>/admin/js/common.js"></script>
	<script src="<%=contextPath%>/admin/assets/js/jquery-form.js"></script>
	<script src="<%=contextPath%>/admin/assets/js/jquery.dataTables.bootstrap.js"></script>
	<script src="<%=contextPath%>/admin/assets/js/jquery.dataTables.bootstrap.js"></script>
	<script src="<%=contextPath%>/admin/assets/js/date-time/bootstrap-datepicker.min.js"></script>
	
	
	<script type="text/javascript">
	
		$(function(){
			initClick();
		});

		function initClick() {
			$(".del").bind("click", function() {
				var id = $(this).attr("dynamicId");
				$("#loading").show();
				$.ajax({
					url : contextPath + '/admin/dynamic',
					type : "POST",
					dataType : 'json',
					data : {
						action : 'delete',
						id:id
					},
					success : function(rs, textStatus, jqXHR) {
						if (rs.success) {
							showMessage(rs.msg);
							window.location.reload();
						} else{
							showMessage(rs.msg);
						}
						$("#loading").hide();
					},
					error : function() {
						$("#loading").hide();
						showMessage("请稍后再试");
					}
				});
			});
			$(".type").bind("click", function() {
				var id = $(this).attr("dynamicId");
				$("#loading").show();
				$.ajax({
					url : contextPath + '/admin/dynamic',
					type : "POST",
					dataType : 'json',
					data : {
						action : 'type',
						id:id
					},
					success : function(rs, textStatus, jqXHR) {
						if (rs.success) {
							showMessage(rs.msg);
							window.location.reload();
						} else{
							showMessage(rs.msg);
						}
						$("#loading").hide();
					},
					error : function() {
						$("#loading").hide();
						showMessage("请稍后再试");
					}
				});
			});
		}

	</script>
</body>
</html>